package com.aaa.salesservice;

import com.aaa.salesservice.config.MyRule;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.ribbon.RibbonClient;
import org.springframework.context.annotation.Bean;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.client.RestTemplate;

/**
 * @Author: YuXin
 * @Date : Created in 2020/11/5 14:45
 * @ClassName : SalesApplication
 * @Description : 熔断  断路器  启动类
 * @Package_Name : com.aaa.salesservice
 */
@SpringBootApplication
@MapperScan("com.aaa.salesservice.dao")
@EnableTransactionManagement
//@EnableDiscoveryClient
@EnableEurekaClient
@RibbonClient(name = "salesClient", configuration = MyRule.class)
@EnableCircuitBreaker //断路器配置注解
//@EnableHystrix
public class SalesApplication {
    public static void main(String[] args) {
        SpringApplication.run(SalesApplication.class, args);
    }

    /**
     * 初始化RestTemplate对象
     */
    @Bean
    @LoadBalanced  //调用远程接口时候   使用配置的负载均衡规则
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }
}
